package com.yuteng.commons.response;

import lombok.Data;

/**
 * 将数据进行封装后返回
 *
 * @version 1.0
 * @author： 余腾
 * @date： 2021-10-20 13:57
 */
@Data
public class ResponseData {
    public static final String DEFAULT_SUCCESS_MESSAGE = "请求成功";
    public static final String DEFAULT_ERROR_MESSAGE = "请求失败";
    public static final Integer DEFAULT_SUCCESS_CODE = 200;
    public static final Integer DEFAULT_ERROR_CODE = 500;
    /**
     * 请求是否成功
     */
    private Boolean success;

    /**
     * 响应状态码
     */
    private Integer code;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应对象
     */
    private Object data;

    public ResponseData() {
    }

    public ResponseData(Boolean success, Integer code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static SuccessResponseData success() {
        return new SuccessResponseData();
    }

    public static SuccessResponseData success(Object object) {
        return new SuccessResponseData(object);
    }

    public static SuccessResponseData success(Integer code, String msg, Object object) {
        return new SuccessResponseData(code, msg, object);
    }

    public static ErrorResponseData error() {
        return new ErrorResponseData();
    }

    public static ErrorResponseData error(Object object) {
        return new ErrorResponseData(object);
    }

    public static ErrorResponseData error(Integer code, String msg, Object object) {
        return new ErrorResponseData(code, msg, object);
    }

}
